import { resolve } from "path";
import banner from "vite-plugin-banner";
import pkg from "./package.json";

export default {
  //   root: resolve(__dirname, "src"),
  plugins: [
    banner(
      `/*!\n * ${pkg.name} | ${pkg.description}\n * Copyright ${pkg.author}\n * Theme scripts & styles\n * \n * @version: v${pkg.version}\n * @create: 2022/05/21\n * @update: ` +
      new Date().toLocaleString() +
      `\n * @author: ${pkg.author}\n * @url: ${pkg.homepage}\n */`
    ),
  ],
  publicDir: "public",
  build: {
    outDir: "dist",
    rollupOptions: {
      input: {
        main: resolve(__dirname, 'index.html'),
        ao: resolve(__dirname, 'ao/index.html'),
        college: resolve(__dirname, 'college/index.html'),
        baidu: resolve(__dirname, 'baidu/hebei.html'),
      },
      output: {
        entryFileNames: 'assets/[name].js',
        chunkFileNames: 'assets/[name].js',
        assetFileNames: (assetInfo) => {
          if (/\.(mp4|webm|ogg|mp3|wav|flac|aac)$/.test(assetInfo.name)) {
            return 'assets/media/[name].[hash][ext]';
          }
          return 'assets/[name].[ext]';
        },
      },
    },
    copyPublicDir: false,
  },
  server: {
    port: 8081,
  },
};
